package com.yk.prize.service.impl;

import java.util.List;
import com.yk.common.utils.DateUtils;
import com.yk.common.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yk.prize.mapper.PrizeMapper;
import com.yk.prize.domain.Prize;
import com.yk.prize.service.IPrizeService;
import com.yk.common.core.text.Convert;

/**
 * 奖项Service业务层处理
 * 
 * @author xufei
 * @date 2025-04-28
 */
@Service
public class PrizeServiceImpl implements IPrizeService 
{
    @Autowired
    private PrizeMapper prizeMapper;

    /**
     * 查询奖项
     * 
     * @param id 奖项主键
     * @return 奖项
     */
    @Override
    public Prize selectPrizeById(Long id)
    {
        return prizeMapper.selectPrizeById(id);
    }

    /**
     * 查询奖项列表
     * 
     * @param prize 奖项
     * @return 奖项
     */
    @Override
    public List<Prize> selectPrizeList(Prize prize)
    {
        return prizeMapper.selectPrizeList(prize);
    }

    /**
     * 新增奖项
     * 
     * @param prize 奖项
     * @return 结果
     */
    @Override
    public int insertPrize(Prize prize)
    {
        prize.setCreateBy(ShiroUtils.getLoginName());
        prize.setCreateTime(DateUtils.getNowDate());
        prize.setDelFlag("0");
        return prizeMapper.insertPrize(prize);
    }

    /**
     * 修改奖项
     * 
     * @param prize 奖项
     * @return 结果
     */
    @Override
    public int updatePrize(Prize prize)
    {
        prize.setUpdateTime(DateUtils.getNowDate());
        prize.setUpdateBy(ShiroUtils.getLoginName());
        return prizeMapper.updatePrize(prize);
    }

    /**
     * 批量删除奖项
     * 
     * @param ids 需要删除的奖项主键
     * @return 结果
     */
    @Override
    public int deletePrizeByIds(String ids)
    {
        return prizeMapper.deletePrizeByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除奖项信息
     * 
     * @param id 奖项主键
     * @return 结果
     */
    @Override
    public int deletePrizeById(Long id)
    {
        return prizeMapper.deletePrizeById(id);
    }
}
